package com.ss.summer.sql.core;

import com.ss.summer.core.exceptions.SummerCustomSqlException;

/**
 * @author xia17
 * @date 2019/8/19 11:03
 */
public class SummerQuery {
    private String sql = "";
    private static final String TABLE_ALIAS = "apply.";

    public SummerQuery like(String tableFiled, String likeValue){
        if (tableFiled == null || "".equals(tableFiled)){
            throw new SummerCustomSqlException("使用SummerQuery查询时表字段不能为空");
        }
        if (likeValue == null || "".equals(likeValue)){
            return this;
        }
        likeValue = "%" + likeValue + "%";
        String tempSql = "  ";
        tempSql += TABLE_ALIAS + tableFiled + "  like  " + "'" + likeValue + "'";
        this.sql = "  AND  " + tempSql;
        return this;
    }

    public String getSql(){
        return sql;
    }

}
